package com.alphaking.Jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.mysql.jdbc.PreparedStatement;

public class JdbcUtils {

	// 数据库驱动
	private static String driver = "com.mysql.jdbc.Driver";
	// url
	private static String url = "jdbc:mysql://127.0.0.1/mydatabase";
	// 账号
	private static String user = "root";
	// 密码
	private static String password = "cx20141142136";
	// 连接
	private static Connection con;

	public static void getConnection() {

		try {
			Class.forName(driver);

			con = DriverManager.getConnection(url, user, password);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public static Connection getCon() {
		return con;// 获得当前的连接
	}

	
}
